import React from 'react'
import { useLocation, useParams } from 'react-router-dom'
import qs from 'qs'
export default function News() {
  const Location = useLocation()
  const { user } = qs.parse(Location.search.split('?')[1])
  const { id } = useParams()
  const  stateList  = Location.state
  return (
    <div>
      <p>用户名：{user} 用户id:{id}</p>
      <ul>
        {
          stateList.map(item=>{
            return <li key={item.id}>{item.name}</li>
          })
        }
      </ul>
    </div>
  )
}